<!DOCTYPE html>
<html>
<head>
<title>新增二维码</title>
#parse("sys/header.html")
<style type="text/css">
	.col-sm-3 {
		padding-top:7px;
	}
</style>
</head>

<body>
<div id="viewapp" v-cloak>
	<div class="form-horizontal" >
		<input type="hidden" id="userId" name="userId" v-model="cashiers.id">
		<input type="hidden" id="merchantId" name="merchantId" v-model="cashiers.merchantId">
	    <div class="form-group">
	   	 	<label class="control-label col-sm-2">企业名称</label>
		   	<div class="col-sm-10">
		      <input type="text" class="form-control"  v-model="cashiers.shopName"  readonly="readonly"/>
		    </div>
		</div>
	    <div class="form-group">
	    	<label class="control-label col-sm-2">收款码名称</label>
	        <div class="col-sm-3">
	        	<input type="text" id="codeName" class="form-control" maxlength="10" placeholder="收款码名称"/>
	        </div>
	    </div>
	    <div class="form-group" align="center" style="padding-top: 20px;">
			<div class="col-sm-2 control-label"></div> 
			<input type="button" class="btn btn-primary" onclick="addQrCode();"  value="确定"/>
		</div>
	</div>
    
</div>

<script type="text/javascript">
var vm = new Vue({
	el:'#viewapp',
	data:{
		title: null,
		cashiers: {},
		selected: '',
	},
	methods: {
		getInfo: function(id){
			$.get("../cashiers/info/"+id, function(r){
                vm.cashiers = r.cashiers;
            });
		},
		view: function(id){
			console.log(this.$route.query.id);
		},
	}
});

$(function() {
	//获取网页参数
	(function($) {
		$.getUrlParam = function(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}
	})(jQuery);
	id = $.getUrlParam('id');
	vm.getInfo(id);
});

function addQrCode(){
	var qrCode={};
	
	var userId = $('#userId').val();
	var merchantId = $('#merchantId').val();
	var codeName = $('#codeName').val();
	
	
	qrCode.userId = userId;
	qrCode.merchantId = merchantId;
	qrCode.codeName = codeName;
	
	console.log(JSON.stringify(qrCode));
	
	var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引  
	  
	$.ajax({
		type: "POST",
	    url: "../cashiers/addQrCode",
	    data: JSON.stringify(qrCode),
	    success: function(r){
	    	alert('操作成功', function(index){
	    		
	    		parent.layer.close(index);
	    		window.parent.location.reload();
			});
		}
	});
}
	
</script>
</body>
</html>